<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META content="text/html; charset=ISO-8859-2" http-equiv="content-type">
<meta name="robots" content="index,follow">
<META NAME="Keywords" CONTENT="regular expressions, regexp">
<meta name="viewport" content="width=device-width, initial-scale=1">
<META NAME="Author" CONTENT="Tomasz Ostrowski">
<META name="description" content="Regular expressions tester and short cheatsheet.">  
<link rel="stylesheet" type="text/css" media="only screen and (max-width: 959px)" href="./css/mobile.css" />
<link rel="stylesheet" type="text/css" media="only screen and (min-width: 960px)" href="./css/main.css" />
<script type="text/javascript" src="./js/tree.js"></script>


<script src="./js/jquery-2.1.3.min.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="./css/jquery-eu-cookie-law-popup.css"/>
<script src="./js/jquery-eu-cookie-law-popup-en.js"></script> -->

<title>erma0.cn: Regular Expressions</title>  
</head>
<body class="eupopup eupopup-bottomleft eupopup-style-compact">

<div id="wrap">
<div id="header">
<div id="header_l">
  <a href="../index.htm">erma0.cn</a>
</div>
<div id="header_r"><A HREF="./regexp.htm" TARGET="_self"><strong>ENGLISH VERSION</strong></A><br><A HREF="./regexp.php?lang=pl" TARGET="_self"><strong>WERSJA POLSKA</strong></A></div>      
</div>

<a href="../bot-trap/">
  <img src="./images/pixel.gif" border="0" alt=" " width="1" height="1">
</a>
     

<script type="text/javascript">
<!-- 
    function TestMatch() {
      var re = new RegExp(document.frmRegexp.regex.value);
      if (document.frmRegexp.test1.value.match(re)) {
        document.frmRegexp.btnMatch1.style.visibility = 'visible';
      } else {
        document.frmRegexp.btnMatch1.style.visibility = 'hidden';
      }
      if (document.frmRegexp.test2.value.match(re)) {
        document.frmRegexp.btnMatch2.style.visibility = 'visible';
      } else {
        document.frmRegexp.btnMatch2.style.visibility = 'hidden';
      }
      if (document.frmRegexp.test3.value.match(re)) {
        document.frmRegexp.btnMatch3.style.visibility = 'visible';
      } else {
        document.frmRegexp.btnMatch3.style.visibility = 'hidden';
      }
      if (document.frmRegexp.test4.value.match(re)) {
        document.frmRegexp.btnMatch4.style.visibility = 'visible';
      } else {
        document.frmRegexp.btnMatch4.style.visibility = 'hidden';
      }
    }
    
    function ShowMatch(inputtext) {
      var re = new RegExp(document.frmRegexp.regex.value);
      var m = re.exec(inputtext);
      if (m == null) {
        alert("No match");
      } else {
        var s = "Match at position " + m.index + ":\n";
        for (i = 0; i < m.length; i++) {
          s = s + m[i] + "\n";
        }
        alert(s);
      }
    }    

//-->
</script>


<div id="main">
<h1>Regular expressions</h1>
      <p>Javascript form to interactively test regular expressions agains multiple text fragments.
      </p>
      <form name="frmRegexp" action="">
				<p>Searched expression (regexp):</p>
			    <p><input type="text" name="regex" value="" onChange="TestMatch()" onKeyUp="TestMatch()" style="width: 550px;"></p>
        <p>Tested text fragments:</p>
			    <p><input type="text" name="test1" value="" onChange="TestMatch()" onKeyUp="TestMatch()" style="width: 430px;">
          <button type=button name="btnMatch1" style="width: 110px"
            onclick="ShowMatch(document.frmRegexp.test1.value)">
            Show match
          </button>
          </p>

			    <p><input type="text" name="test2" value="" onChange="TestMatch()" onKeyUp="TestMatch()" style="width: 430px;">
          <button type=button name="btnMatch2" style="width: 110px"
            onclick="ShowMatch(document.frmRegexp.test2.value)">
            Show match
          </button>
          </p>

			    <p><input type="text" name="test3" value="" onChange="TestMatch()" onKeyUp="TestMatch()" style="width: 430px;">
          <button type=button name="btnMatch3" style="width: 110px"
            onclick="ShowMatch(document.frmRegexp.test3.value)">
            Show match
          </button>
          </p>

			    <p><input type="text" name="test4" value="" onChange="TestMatch()" onKeyUp="TestMatch()" style="width: 430px;">
          <button type=button name="btnMatch4" style="width: 110px"
            onclick="ShowMatch(document.frmRegexp.test4.value)">
            Show match
          </button>
          </p>


			</form>
			<p>Basic regular expression elements:
			<table border="1" width="100%" cellspacing="0" cellpadding="3"
      style="font-family: courier, monospace; font-size: small;">

			<tr><td colspan="2">Literals</td>
			</tr>

      <tr>
			<td>a B G 7 0 @ - = %</td><td>letters and digits match exactly</td>
			</tr>

      <tr>
			<td>\. \\ \$ \[</td><td>escaped special characters</td>
			</tr>

      <tr>
			<td>\n \r \t \dec_code \xhex_code</td><td>non printable characters</td>
			</tr>


			<tr><td colspan="2">Anchors</td>
			</tr>

      <tr>
			<td>^ $</td><td>begin/end of line</td>
			</tr>

      <tr>
			<td>\b</td><td>word boundary</td>
			</tr>

      <tr>
			<td>\B</td><td>not a word boundary</td>
			</tr>


			<tr><td colspan="2">Character groups</td>
			</tr>

      <tr>
			<td>.</td><td>any char except newline</td>
			</tr>
			
      <tr>
			<td>\d \D \s \S \w</td><td>decimal digit, non digit, whitespace, not whitespace, char from [a-zA-Z0-9_]</td>
			</tr>
			
      <tr>
			<td>[char_list]</td><td>any char from list, i.e. [0123456789], [a-zA-Z0-9_]</td>
			</tr>
			
      <tr>
			<td>[^char_list]</td><td>any char outside list, i.e. [^0-9]</td>
			</tr>
			

			<tr><td colspan="2">Counts - add ? for non-greedy.</td>
			</tr>

      <tr>
			<td>expr*</td><td>0 or more</td>
			</tr>

      <tr>
			<td>expr?</td><td>0 or 1</td>
			</tr>

      <tr>
			<td>expr+</td><td>1 or more</td>
			</tr>

      <tr>
			<td>expr{n,m}</td><td>n to m</td>
			</tr>

      <tr>
			<td>expr{n}</td><td>exactly n</td>
			</tr>

      <tr>
			<td>expr{n,}</td><td>n or more</td>
			</tr>

			<tr><td colspan="2">Alternation: expr1|expr2</td>
			</tr>
			
			</table>
  </div>
<div id="sidebar">
<h3>Sitemap</h3>

<ul id="tree0" class="tree">

    <li ><a>PROJECTS</a>
    <ul>
    <li><A HREF="../programator.htm" TARGET="_self">FLASH 49F programmer</A></li> 
    </ul>
    </li>

 
    <li><a>ONLINE TOOLS</a>
    <ul>
    <li><a href="./base64.htm" TARGET="_self">Base64 -&gt; HEX</A></li>
    <li><a href="./base32.htm" TARGET="_self">Base32 -&gt; HEX</a></li>
    <li><a href="./base32hex.htm" TARGET="_self">Base32hex -&gt; HEX</a></li>
    <li><a href="./ascii.htm" TARGET="_self">ASCII -&gt; HEX</a></li>
    <li><a href="./ascii_uN.htm" TARGET="_self">ASCII -&gt; u16/u32/u64 HEX</a></li>            
    <li><a href="./hex_to_base64.htm" TARGET="_self">HEX -&gt; Base64</a></li>
    <li><a href="./text_to_base64.htm" TARGET="_self">Text -&gt; Base64</a></li>
    <li><a href="./hex_to_base32.htm" TARGET="_self">HEX -&gt; Base32</a></li>
    <li><a href="./hex_to_base32hex.htm" TARGET="_self">HEX -&gt; Base32hex</a></li>
    <li><a href="./hex_to_ascii.htm" TARGET="_self">HEX -&gt; ASCII</a></li>
    <li><a href="./hex_to_dec.htm" TARGET="_self">HEX -&gt; DEC</a></li>	
    <li><a href="./dec_to_ascii.htm" TARGET="_self">DEC -&gt; ASCII</a></li>
    <li><a href="./bin_to_32bit_hex.htm" TARGET="_self">BIN &lt;-&gt; 32-bit hex</a></li>    
    <li><a href="./md5.htm" TARGET="_self">MD5 calculator</a></li>
    <li><a href="./sha1.htm" TARGET="_self">SHA1 calculator</a></li>    
    <li><a href="./regexp.htm" TARGET="_self">Regular exp.</a></li>
    <li><a href="./cpp_text_escape.htm" TARGET="_self">Text -&gt; Cpp</a></li>
    <li><a href="./cpp_unescape.htm" TARGET="_self">Cpp -&gt; text</a></li>
    <li><a href="./pascal_escape.htm" TARGET="_self">Text -&gt; Pascal</a></li>        
    <li><a href="./hex_to_file.htm" TARGET="_self">HEX -&gt; file</a></li>
    <li><a href="./file_to_hex.htm" TARGET="_self">File -&gt; HEX</a></li>
    <li><a href="./file_to_base64.htm" TARGET="_self">File -&gt; Base64</a></li>    
    <li><a href="./html_list_gen.htm" TARGET="_self">Text -&gt; HTML ul</a></li>
    <li><a href="./crc8.htm" TARGET="_self">CRC8</a></li>
    <li><a href="./wave_gen.htm" TARGET="_self">WAVE generator</a></li>
    <li><a href="./bin_decoder.htm" TARGET="_self">Bin decoder</a></li>
    <li><a href="./rc4.htm" TARGET="_self">RC4</a></li>          
    <li><a href="./xor.htm" TARGET="_self">XOR</a></li>
    <li><a href="./inv.htm" TARGET="_self">Inverting bits</a></li>
    <li><a href="./par_resistors.htm" TARGET="_self">Par. resistors search</a></li>
    <li><a href="./unique_str.htm" TARGET="_self">Deduplicate / sort</a></li>        
    <li><a href="./base64_to_PEM.htm" TARGET="_self">Base64 -&gt; PEM</a></li>
    <li><a href="./PEM_to_base64.htm" TARGET="_self">PEM -&gt; base64</a></li>
    <li><a href="./diskstats.htm" TARGET="_self">/proc/diskstats</a></li>    
    </ul>
    </li> 


    <li><A HREF="../contact2.htm" TARGET="_self">Contact</A></li></ul>
<script type="text/javascript">
//<!--
new tree("tree0");
//-->
</script>

<br>  
<br>  
<br>  





  <br>    

        
    
</div>


<div id="footer">




  
</div>


<br>
<div id="footer2"><p>      
            <!-- <font size="-2">&nbsp;"Cookie monsters": 5583818&nbsp;&nbsp;&nbsp;&nbsp;Parse time:&nbsp;0.000 s</font> -->

  </p>
	</div>
</div>
</body>
</html>

